package leetcode2;

import java.util.HashSet;
import java.util.Set;

public class Day8 {

    public static void main(String[] args) {
        System.out.println(10/0);
    }

    //128.最长连续序列
    public int longestConsecutive(int[] nums) {
        //1.0-9
        Set<Integer> set = new HashSet<>();
        for(int x:nums) {
            set.add(x);
        }
        int len=0;
        for(int x : set) {
            if(set.contains(x-1)) continue;
            int y=x+1;
            while(set.contains(y)) {
                y++;
            }
            len = Math.max(len,y-x);
        }
        return len;
    }


}
